<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <script src="../js/babel.min.js"></script>

  <script type="text/babel">
    // 1 创建类式组件
    class Weather extends React.Component {
      // constructor 调用1次
      state = {
        isHot: true,
        wind: '微风'
      }
      // 点几次调用几次
      handleClick = () => {

        const isHot = this.state.isHot
        this.setState({ isHot: !isHot })
      }
      // render调用 1+n 次
      render() {
        const { isHot, wind } = this.state
        return (
          <div>
            <h2 onClick={this.handleClick}>今天天气很{isHot ? '炎热' : '凉爽'} {wind}</h2>
          </div>
        )
      }
    }
    // 2 渲染组件到页面
    ReactDOM.render(<Weather />, document.getElementById("app"))

  </script>
</body>

</html>